home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / UNITS / YAKMOUSE.CPP < prev    next >
C/C++ Source or Header  |  1993-02-14  |  2KB  |  119 lines

  1. #define YAKMOUSEUNIT
  2.  
  3. #include "xlib.h"
  4. #include "yakmouse.h"
  5. #include "xmouse.h"
  6.  
  7. /*
  8. 00000010 2
  9. 00000111 7
  10. 00001111 15
  11. 00011111 31
  12. 00111111 63
  13. 00001100 12
  14. 00011000 24
  15. 00110000 48
  16. 00000000
  17. 00000000
  18. 00000000
  19. 00000000
  20. 00000000
  21. 00000000
  22. 00000000
  23. */
  24.  
  25. unsigned char standardMouse[] = {2, 7, 15, 31, 63, 12, 24, 48,0,0,0,0,0,0};
  26.  
  27. yakMouse mouse;
  28.  
  29. void yakMouse::beStandardMouse(void)
  30. {
  31.   x_define_mouse_cursor(standardMouse, 15);
  32. }
  33.  
  34. void yakMouse::init(void)
  35. {
  36.   x_mouse_init();
  37.   beStandardMouse();
  38.   show();
  39. }
  40.  
  41. void yakMouse::remove(void)
  42. {
  43.   x_mouse_remove();
  44. }
  45.  
  46. void yakMouse::show(void)
  47. {
  48.   x_show_mouse();
  49. }
  50.  
  51. void yakMouse::hide(void)
  52. {
  53.   x_hide_mouse();
  54. }
  55.  
  56. void yakMouse::setImage(char * mouseDef, int color)
  57. {
  58.   x_define_mouse_cursor(mouseDef, color);
  59. }
  60.  
  61. word yakMouse::x(void)
  62. {
  63.   return MouseX;
  64. }
  65.  
  66. word yakMouse::y(void)
  67. {
  68.   return MouseY;
  69. }
  70.  
  71.  
  72. void yakMouse::display(int x, int y, int topclip, int botclip, word offset)
  73. {
  74.   x_put_cursor(x, y, topclip, botclip, offset);
  75. }
  76.  
  77. //word yakMouse::numberOfButtons(void)
  78. //{
  79. //  return x_mouse_nbuts;
  80. //}
  81.  
  82. word yakMouse::buttonStatus(void)
  83. {
  84.   return MouseButtonStatus;
  85. }
  86.  
  87. byte yakMouse::isPressed(buttonType myButtons)
  88. {
  89.   return (MouseButtonStatus & myButtons);
  90. }
  91.  
  92. byte yakMouse::isClicked(buttonType myButtons)
  93. {
  94.   static buttonType oldButtons;
  95.   buttonType newButtons = (MouseButtonStatus & myButtons);
  96.   if (myButtons == reset)
  97.   {
  98.     oldButtons = noButtons;
  99.     return 0;
  100.   }
  101.   if (newButtons == noButtons)
  102.   {
  103.     oldButtons = noButtons;        //no buttons at all
  104.     return 0;
  105.   }
  106.   else if (newButtons == oldButtons)  //something's held down..
  107.     return 0;
  108.   else
  109.   {
  110.     oldButtons = newButtons;        //a new button is pressed.
  111.     return (newButtons);
  112.   }
  113. }
  114.  
  115. byte yakMouse::isInBox(int x1, int y1, int x2, int y2)
  116. {
  117.   return (((MouseX >= x1) && (MouseX <= x2)) &&
  118.       ((MouseY >= y1) && (MouseY <= y2)));
  119. }